import java.util.ArrayList;

public class Menu {

	
	private ArrayList<MenuItem> items = new ArrayList<MenuItem>();	
	private MenuIterator iter;
	
	
	public Menu(){
		
		items.add(new MenuItem("Chicken and Rice", 9.99, "Chicken", true));
		items.add(new MenuItem("Chicken and Brocolli", 10.99, "Chicken", true));
		items.add(new MenuItem("Shrimp roll", 1.99, "Shrimp", false));
		items.add(new MenuItem("10 Chiken Wings", 5.99, "Chicken", false));
		items.add(new MenuItem("Beef Skewers", 4.99, "Beef", false));
		items.add(new MenuItem("Chicken Chow Mein", 7.99, "Chicken", false));
		items.add(new MenuItem("Beef Lo Mein", 7.99, "Beef", false));
		items.add(new MenuItem("Sweet and Sour Pork", 7.49, "Pork", false));
		items.add(new MenuItem("Mongolian Chicken", 8.50, "Chicken", false));
		items.add(new MenuItem("Roast Pork w. Garlic Sauce", 7.25, "Pork", false));
		items.add(new MenuItem("Mixed Vegetables", 4.99, "Vegetables", true));
		items.add(new MenuItem("Shrimp w. Broccoli", 11.99, "Shrimp", true));
		items.add(new MenuItem("General Tso's Chicken", 8.99, "Chicken", false));
		items.add(new MenuItem("Sesame Beef", 10.99, "Beef", false));
		items.add(new MenuItem("Chicken Nuggets", 3.99, "Chicken", false));
		
	}
	
	public Menu(ArrayList<MenuItem> newMenu)
	{
		items = newMenu;
		
	}
	
	public void add(MenuItem newItem)
	{		
		//System.out.println(items.size());
		items.add(newItem);
	}
	
	public ArrayList<MenuItem> getItems()
	{
		return items;
	}
	/*
	public MenuIterator createIterator(int choice)
	{
		
		
		switch(choice)
		{
		
		case 1:
			iter = new CompleteMenuIterator(items);
			break;
		case 2:	
			iter = new PriceMenuIterator(items);
			break;
		case 3:
			iter = new IngredientMenuIterator(items);
			break;
		case 4: 
			iter = new HeartHealthyMenuIterator(items);
			break;
		default:			
			
			break;		
		
		}
		
		return iter;
		
	}

	public void setMenuItems(ArrayList<MenuItem> newMenu)
	{
		items = newMenu;
	}
		*/
	public Menu getMenu()
	{	
		//System.out.println("SIZE "+items.size()+ " " + getItems().size());	
		iter = new CompleteMenuIterator(items);
		
		//System.out.println("ITERATING");
		
		return traverseMenu(iter);		
	}
	
	public Menu getPriceMenu(Double price)
	{				
		iter = new PriceMenuIterator(items, price);
		return traverseMenu(iter);		
	}
	
	public Menu getIngredientMenu(String ingredient)
	{		
		iter = new IngredientMenuIterator(items, ingredient);
		
		return traverseMenu(iter);		
	}
	
	public Menu getHearthHealthyMenu()
	{		
		iter = new HeartHealthyMenuIterator(items);
		
		return traverseMenu(iter);		
	}
	
	
	private Menu traverseMenu(MenuIterator iter)
	{
		ArrayList<MenuItem> newMenu = new ArrayList<MenuItem>();
		//System.out.println("TRAVERSING MENU");
		
		while(iter.hasNext())
		{			
			newMenu.add(iter.next());
		}
		Menu iterMenu = new Menu(newMenu);
		return iterMenu;
		
	}
	
}
